﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Com.AlbLab.GEP.Domain;
using common;

using common.pages;

namespace Com.AlbLab.CR.Web.pages
{
    public partial class RicercaStampa : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.IsInRole("ACQPRI"))
            {
                radioPriCod.Visible = false;
                RadioPriNom.Visible = false;
            }
            if (!User.IsInRole("ACQAZ"))
            {
                radioAzCod.Visible = false;
                RadioAzNom.Visible = false;
            }
            if (!User.IsInRole("SPE"))
            {
                RadioSpeCod.Visible = false;
                RadioSpeNom.Visible = false;
            }
            if (!User.IsInRole("COMP"))
            {
                RadioConsCod.Visible = false;
                RadioConsNom.Visible = false;
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                //ricerca schede aziende
                if (RadioAzNom.Checked)
                {
                    //GrigliaGenerica1.NumColonne = 5;
                    //GrigliaGenerica1.H0 = "Partita Iva";
                    //GrigliaGenerica1.H1 = "Ragione Sociale";
                    //GrigliaGenerica1.H2 = "Centro Raccolta";
                    //GrigliaGenerica1.H3 = "Data Conferimento";
                    ////IList<ConfAziendaEntity> searchResult = null;
                    //searchResult = null;// base.ServiceConfAzienda().LoadConferimentoByPartialRagSoc(textFilter.Text.Trim(), false);
                    //GrigliaGenerica1.Visible = true;
                    //GrigliaGenerica1.DataSource = null;// common.ToGenericListTransformers.transform(searchResult, false);
                    //C1.Visible = true;
                }
                else if (radioAzCod.Checked)
                {
                    //ConfAziendaEntity searchResult = null;
                    //decimal s;
                    //if (decimal.TryParse(textFilter.Text.Trim(),out s))
                    //{
                    //    searchResult = base.ServiceConfAzienda().LoadConferimentoById(decimal.Parse(textFilter.Text.Trim()));
                    //    GrigliaGenerica1.Visible = false;
                    //    if (searchResult == null) base.info.AddMessage("Nessun Ritrovamento", LivelloMessaggio.INFO);
                    //    else
                    //    {
                    //        common.TempSession.setBag("CODICE", searchResult.Id);
                    //        Response.Redirect("ConfNonDomestico.aspx");
                    //    };
                    //}
                    //else base.info.AddMessage("La ricerca per codice prevede un parametro di tipo numerico", LivelloMessaggio.INFO);
                }

              
            }
            catch (ManagedException e0x)
            {
                ((BasePage)this.Page).info.AddMessage(e0x);
            }
        }

        protected void GrigliaGenerica1_OnSelect(string commandName, GenericListDTO row)
        {
            GrigliaGenerica1.Clear();
            common.TempSession.setBag("CODICE", row.Id.Split('/')[0]);
            if(RadioAzNom.Checked)
                Response.Redirect("ConfNonDomestico.aspx");
            else if (RadioPriNom.Checked)
            {
                if(row.Id.Contains("/3"))
                    Response.Redirect("ConfDomiciliare.aspx");
                else if (row.Id.Contains("/4"))
                Response.Redirect("ConfDomiciliareSfalci.aspx");
                else
                    Response.Redirect("ConfDomestico.aspx");
            }
            else if (RadioSpeNom.Checked)
                Response.Redirect("SpedizioneRecupero.aspx");
            else if (RadioConsNom.Checked)
                Response.Redirect("ConsegnaCompostiere.aspx");
            else if (RadioDiffNom.Checked)
                Response.Redirect("ContenitoriRaccoltaDifferenziata.aspx");
            else if (RadioSmarrNom.Checked)
                Response.Redirect("DichiarazionePerditaPossesso.aspx");
        }
    }
}